package com.fwmagic.flink.streaming;

import com.fwmagic.flink.datasource.SourceFromMysql;
import com.fwmagic.flink.pojo.Student;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.streaming.api.functions.sink.PrintSinkFunction;
import org.apache.flink.streaming.api.scala.DataStream;
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment;

public class StreamingDemoFromMysql {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);
        DataStream<Student> dataStream = env.addSource(new SourceFromMysql(), TypeInformation.of(Student.class));

        //dataStream.print();

        //dataStream.print()和下面手动添加的PrintSink是等效的
        dataStream.addSink(new PrintSinkFunction<>());

        env.execute("StreamingDemoFromMysql");

    }
}
